package leetcode100;

import java.util.Scanner;

/**
 * @author shkstart
 * @create 2022-12-26-21:03
 */
public class Meme25_2 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while(scanner.hasNext()) {
            String str = scanner.next();

            while (str.length() > 1) {
                int count = 0;
                for (int i = 0; i < str.length(); i++) {
                    count += str.charAt(i) - '0';
                }
                str = String.valueOf(count);

            }
            System.out.println(str);

        }
        }
}
